package cn.wolfcode.shop.service.impl;

import cn.wolfcode.shop.domain.SkuPropertyValue;
import cn.wolfcode.shop.mapper.SkuPropertyValueMapper;
import cn.wolfcode.shop.service.IPropertyValueService;
import cn.wolfcode.shop.service.ISkuPropertyValueService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by wolfcode on 2018/8/17.
 */
@Service@Transactional
public class SkuPropertyValueServiceImpl implements ISkuPropertyValueService {
    @Autowired
    private SkuPropertyValueMapper skuPropertyValueMapper;

    public List<SkuPropertyValue> queryBySkuPropertyId(Long skuPropertyId) {
        return skuPropertyValueMapper.queryBySkuPropertyId(skuPropertyId);
    }

    public void saveOrUpdateBatch(List<SkuPropertyValue> skuPropertyValueList) {
        for(SkuPropertyValue pv:skuPropertyValueList){
            if(pv.getId()==null){
                skuPropertyValueMapper.insert(pv);
            }else{
                skuPropertyValueMapper.updateByPrimaryKey(pv);
            }
        }
    }

    public void delete(Long propertyValueId) {
        skuPropertyValueMapper.deleteByPrimaryKey(propertyValueId);
    }
}
